import { defineStore } from 'pinia'
import { ref } from 'vue'
import { acountLogin } from '@/api/login'
//import { getServerCart } from '@/api/cart'

const useUserStore = defineStore('user', () => {

  // state 数据
  const token = ref<string>('')
 //const userPhone = ref<string>('')

  // action 方法
  const loginAction=async(tel:any,password:any)=>{
    const result=await acountLogin(tel,password)
    console.log('登录结果',result)
    /* if(result.data.data.status==200){
      showNotify(result.data.data.message)
      router.push('/mine')
  
    } */
    token.value=result.data.data.token
   // userPhone.value=result.data.data.userinfo
    return result
  
  }

  return {
    token,
   // userid,
    loginAction,
  }

  
},
{
  persist:true
}
)

export default useUserStore
